package ltd.latewhale.whalenest.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ltd.latewhale.whalenest.DTO.commentsCountDTO;
import ltd.latewhale.whalenest.mapper.commentsMapper;
import ltd.latewhale.whalenest.model.commentsDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class commentsService extends ServiceImpl<commentsMapper, commentsDO> {

    @Autowired
    private commentsMapper commentsMapper;

    public commentsDO getById(String id) {
        commentsDO commentss = commentsMapper.selectById(id);
        return  commentss;
    }

    public List<commentsDO> getcomments() {
        List<commentsDO> commentss = commentsMapper.selectList(null);
        return commentss;
    }
    
    public Integer deleteId(Integer id) {

        return commentsMapper.deleteById(id);
    }

    public Integer postcomments(commentsDO dto){

        return commentsMapper.insert(dto);
    }

    public List<commentsCountDTO> getCount(){

        List<commentsCountDTO> datas = commentsMapper.getCount();
        return datas;
    }
}
